package drds.binlog.protocol;

import com.google.protobuf.ByteString;
import drds.binlog.protocol.entry_protocol_proto.Entry;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class Message implements Serializable
{

    private static final long serialVersionUID = 1234034768477580009L;

    private long id;
    @Deprecated
    private List<Entry> entryList = new ArrayList<Entry>();
    private boolean raw = true;
    private List<ByteString> rawEntryList = new ArrayList<ByteString>();

    public Message(long id, List<Entry> entryList)
    {
        this.id = id;
        this.entryList = entryList == null ? new ArrayList<Entry>() : entryList;
        this.raw = false;
    }

    public Message(long id, boolean raw, List entryList)
    {
        this.id = id;
        if (raw)
        {
            this.rawEntryList = entryList == null ? new ArrayList<ByteString>() : entryList;
        } else
        {
            this.entryList = entryList == null ? new ArrayList<Entry>() : entryList;
        }
    }

    public Message(long id)
    {
        this.id = id;
    }

    public long getId()
    {
        return id;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public List<Entry> getEntryList()
    {
        return entryList;
    }

    public void setEntryList(List<Entry> entryList)
    {
        this.entryList = entryList;
    }

    public void addEntry(Entry entry)
    {
        this.entryList.add(entry);
    }

    public void addRawEntry(ByteString rawEntry)
    {
        this.rawEntryList.add(rawEntry);
    }

    public List<ByteString> getRawEntryList()
    {
        return rawEntryList;
    }

    public void setRawEntryList(List<ByteString> rawEntryList)
    {
        this.rawEntryList = rawEntryList;
    }

    public boolean isRaw()
    {
        return raw;
    }

    public void setRaw(boolean raw)
    {
        this.raw = raw;
    }


}
